<?php
require(dirname(__FILE__)."/includes/init.php");
if(isset($_REQUEST['Submit'])){
	$id = $_REQUEST['id'];
	$title = $_REQUEST['title'];
	$content = addslashes($_REQUEST['content']);
	$sql = "update hairarticle set title = '".$title."', content = '".$content."' where id = $id";
	$GLOBALS['db']->dbquery($sql);
}
$sql = "select count(*) as num from hairarticle";
$result = $GLOBALS['db']->dbGetRow($sql);
$num = rand(1,$result['num']);

if(isset($_REQUEST['id'])){
	$num = $_REQUEST['id'];
}



$sqlS = "select * from hairArticle where id = $num";

$resultArr = $GLOBALS['db']->dbGetRow($sqlS);

?>
<form action="" method="post">
<table width="600" border="0">
  <tr>
    <td>Id</td>
    <td><input type="text" name="id" value="<?php echo addslashes($resultArr['id']);?>" /></td>
  </tr>
  <tr>
    <td>title</td>
    <td><input name="title" type="text" value="<?php echo addslashes($resultArr['title']);?>" size="100" maxlength="100"/></td>
  </tr>
  <tr>
    <td>content</td>
    <td><textarea name="content" cols="120" rows="20"><?php echo $resultArr['content'];?></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="提交" /></td>
  </tr>
</table>
</form>